from django.shortcuts import render

# Create your views here.
from xg.models import *
from datetime import *
def index(request):
    return render(request, 'index.html')

def get_xgdata(request):
    # 原始数据集
    xgdata_ODS = xgdata.objects.all()
    # 统计计算后的数据集
    xgdata_sum = xgdata_Sum_By_Date.objects.all()
    xgdata_new = xgdata_Sum_By_Date.objects.last()
    # 原始数据集映射后，筛选日期
    xgdata_pro = xgdata.objects.filter(date_day=date(2020,7,27))
    # 筛选湖北
    xgdata_hubei = xgdata.objects.filter(
        pro_cn="湖北",
        date_day__range = (date(2020,1,24),date(2020,3,31))
    )
    context = {'xgdata': xgdata_ODS,
               'xgdata_sum':xgdata_sum,
               'xgdata_new':xgdata_new,
               'xgdata_pro':xgdata_pro,
               'xgdata_hubei':xgdata_hubei,
               }
    return render(request,'show.html',context)
